#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QDate>
#include <QSqlDatabase>
#include <QLabel>
#include <QSettings>

#include "dialogaddfood.h"
#include "dialogwebkitreportview.h"
#include "dialogmealdatamanage.h"
#include "dialogsettings.h"
#include "dialogtimeperiodsetting.h"

#include "mealmodel.h"
#include "mealdatareader.h"
#include "webkitreport.h"

namespace Ui {
    class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

private slots:
    void recalculateDisplay();

    void on_pushButtonAddBreakFast_clicked();

    void on_pushButtonRemoveBreakFast_clicked();

    void on_pushButtonAddLunch_clicked();

    void on_pushButtonRemoveLunch_clicked();

    void on_pushButtoAddDinner_clicked();

    void on_pushButtonRemoveDinner_clicked();

    void on_calendarWidget_clicked(const QDate &date);

    void on_actionQuit_triggered();

    void on_actionImport_triggered();

    void on_actionManageMealData_triggered();

    void on_actionAboutQt_triggered();

    void on_actionWeboldal_triggered();

    void on_actionDietarySettings_triggered();

    void on_actionWeeklyReport_triggered();

    void on_actionPrintMenuCard_triggered();

    void on_actionTimePeriod_triggered();

private:
    MealDataReader *reader;
    MealModel *breakFastModel, *dinnerModel, *lunchModel;
    Ui::MainWindow *ui;
    QSqlDatabase db;
    QSqlQuery *m_query;
    WebkitReport *m_report;
    DialogTimePeriodSetting timePeriodSettings;
    QLabel *m_statusLabel;
    QSettings settings;

    DialogWebKitReportView *m_reportView;
    DialogAddFood *m_addFoodDialog;
    DialogMealDataManage *m_mealManageDialog;
    DialogSettings *dietarySettings;

    void setDailyMealSumData(MealModel::MealType meal, double cal = 0, double fat = 0, double protein = 0, double ch = 0, double cost = 0);
    void setDailySumData(double cal = 0, double fat = 0, double protein = 0, double ch = 0, double cost = 0);
    void setPeriodSumData(double cal = 0, double fat = 0, double protein = 0, double ch = 0, double cost = 0);

    bool setLabelValue(QString labelName, double value, QString suffix);
};

#endif // MAINWINDOW_H
